<!DOCTYPE html>
<html lang="en">

<!-- Head tag -->
<head><meta name="generator" content="Hexo 3.9.0">

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!--Description-->
    
        <meta name="description" content="tars环境部署注意：这里依据Git上的tars搭建步骤整理而来，且必须依赖mysql  且未和任何业务有瓜葛  纯框架环境搭建
参考： 
12https://max.book118.com/html/2017/0527/109698528.shtmhttps://github.com/TarsCl">
    

    <!--Author-->
    
        <meta name="author" content="ck">
    

    <!--Open Graph Title-->
    
        <meta property="og:title" content="tars框架环境基础搭建">
    

    <!--Open Graph Description-->
    

    <!--Open Graph Site Name-->
    <meta property="og:site_name" content="CK&#39;s blogs">

    <!--Type page-->
    
        <meta property="og:type" content="article">
    

    <!--Page Cover-->
    

    <meta name="twitter:card" content="summary">
    

    <!-- Title -->
    
    <title>tars框架环境基础搭建 - CK&#39;s blogs</title>

    <!-- Bootstrap Core CSS -->
    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">

    <!-- Custom Fonts -->
    <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="//oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="//oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

    <!-- Gallery -->
    <link href="//cdnjs.cloudflare.com/ajax/libs/featherlight/1.3.5/featherlight.min.css" type="text/css" rel="stylesheet">

    <!-- Custom CSS -->
    <link rel="stylesheet" href="/blog/css/style.css">

    <!-- Google Analytics -->
    


</head>


<body>

<div class="bg-gradient"></div>
<div class="bg-pattern"></div>

<!-- Menu -->
<!--Menu Links and Overlay-->
<div class="menu-bg">
    <div class="menu-container">
        <ul>
            
            <li class="menu-item">
                <a href="/blog/">
                    Home
                </a>
            </li>
            
            <li class="menu-item">
                <a href="/blog/archives">
                    Archives
                </a>
            </li>
            
            <li class="menu-item">
                <a href="/blog/2019/09/04/本人简历/">
                    About
                </a>
            </li>
            
            <li class="menu-item">
                <a href="/blog/tags">
                    Tags
                </a>
            </li>
            
            <li class="menu-item">
                <a href="/blog/categories">
                    Categories
                </a>
            </li>
            
            <li class="menu-item">
                <a href="/blog/contact.html">
                    Contact
                </a>
            </li>
            
        </ul>
    </div>
</div>

<!--Hamburger Icon-->
<nav>
    <a href="#menu"></a>
</nav>

<div class="container">

    <!-- Main Content -->
    <div class="row">
    <div class="col-sm-12">

        <!--Title and Logo-->
        <header>
    <div class="logo">
        <a href="/blog/"><i class="logo-icon fa fa-cube" aria-hidden="true"></i></a>
        
    </div>
</header>

        <section class="main">
            
<div class="post">

    <div class="post-header">
        <h1 class="title">
            <a href="/blog/2019/10/25/tars框架环境基础搭建/">
                tars框架环境基础搭建
            </a>
        </h1>
        <div class="post-info">
            
                <span class="date">2019-10-25</span>
            
            
            
        </div>
    </div>

    <div class="content">

        <!-- Gallery -->
        

        <!-- Post Content -->
        <h1 id="tars环境部署"><a href="#tars环境部署" class="headerlink" title="tars环境部署"></a>tars环境部署</h1><p>注意：这里依据Git上的tars搭建步骤整理而来，且必须依赖mysql  且未和任何业务有瓜葛  纯框架环境搭建</p>
<p>参考： </p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">https://max.book118.com/html/2017/0527/109698528.shtm</span><br><span class="line">https://github.com/TarsCloud/Tars/blob/master/Install.zh.md</span><br></pre></td></tr></table></figure>

<p>环境： centos7.3-x86_64  kernel ：3.10    </p>
<p>上刺刀， 不是 上干货！</p>
<p>1,依赖</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">yum install mpfr -y</span><br><span class="line">yum install gmp -y</span><br><span class="line">yum install *mpc* -y</span><br><span class="line">yum install glibc-static libstdc++-static -y</span><br><span class="line">yum -y install gcc gcc-c++</span><br><span class="line">yum -y install autoconf automake libtool curl make g++ unzip zlib zlib-devel</span><br><span class="line">yum install glibc-devel -y</span><br><span class="line">yum install cmake -y</span><br><span class="line">yum install perl -y</span><br><span class="line">yum install -y git</span><br><span class="line">yum install ncurses-devel -y</span><br></pre></td></tr></table></figure>

<p>2，安装gcc</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"># 安装，下载好包并放在/mnt下面</span><br><span class="line">cd /mnt</span><br><span class="line">wget http://ftp.gnu.org/gnu/gcc/gcc-6.3.0/gcc-6.3.0.tar.gz</span><br><span class="line">tar  fx gcc-6.3.0.tar.gz</span><br><span class="line">cd gcc-6.3.0/</span><br><span class="line">./contrib/download_prerequisites</span><br><span class="line">./configure -enable-checking=release -enable-languages=c,c++ -disable-multilib</span><br><span class="line">make -j2</span><br><span class="line">make install</span><br><span class="line"># 配置gcc环境变量</span><br><span class="line">mv /usr/bin/gcc /usr/bin/gcc4.4.7</span><br><span class="line">ln -s /usr/local/bin/gcc /usr/bin/gcc</span><br><span class="line">mv /usr/bin/g++ /usr/bin/g++4.4.7</span><br><span class="line">ln -s /usr/local/bin/g++ /usr/bin/g++</span><br><span class="line">mv /usr/bin/cc /usr/bin/cc4.4.7</span><br><span class="line">ln -s /usr/local/bin/cc /usr/bin/cc</span><br><span class="line">mv /usr/bin/c++ /usr/bin/c++4.4.7</span><br><span class="line">ln -s /usr/local/bin/c++ /usr/bin/c++</span><br><span class="line">gcc --version</span><br><span class="line">echo &quot;/usr/local/lib64&quot; &gt;&gt;/etc/ld.so.conf</span><br><span class="line">ldconfig</span><br></pre></td></tr></table></figure>

<p>3，安装protoc-3.6.1</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">cd /mnt</span><br><span class="line">unzip protobuf-master.zip</span><br><span class="line">cd protobuf-master/</span><br><span class="line">./autogen.sh</span><br><span class="line">./configure</span><br><span class="line">make</span><br><span class="line">make check</span><br><span class="line">make install</span><br><span class="line">protoc --\version</span><br></pre></td></tr></table></figure>

<p>4，安装jdk</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">cd /mnt</span><br><span class="line">tar xf jdk-8u181-linux-x64.tar.gz -C /usr/java</span><br><span class="line">cat &gt;&gt; /etc/profile &lt;&lt; EOF</span><br><span class="line">export JAVA_HOME=/usr/java/jdk1.8.0_181</span><br><span class="line">export JRE_HOME=\$&#123;JAVA_HOME&#125;/jre</span><br><span class="line">export CLASSPATH=.:\$&#123;JAVA_HOME&#125;/lib:\$&#123;JRE_HOME&#125;/lib</span><br><span class="line">export PATH=\$&#123;JAVA_HOME&#125;/bin:\$PATH</span><br><span class="line">EOF</span><br><span class="line"></span><br><span class="line">source /etc/profile</span><br><span class="line">echo $JAVA_HOME</span><br></pre></td></tr></table></figure>

<p>5,安装mysql-5.6</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"># 安装mysql</span><br><span class="line">useradd mysql</span><br><span class="line">tar fx mysql-5.6.35.tar.gz</span><br><span class="line">cd  mysql-5.6.35/</span><br><span class="line">cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci</span><br><span class="line">make &amp;&amp; make install</span><br></pre></td></tr></table></figure>

<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">#配置mysql</span><br><span class="line">yum -y install perl</span><br><span class="line">cd /usr/local/mysql/</span><br><span class="line">rm  -rf /usr/local/mysql/data/</span><br><span class="line">mkdir -p /data/mysql-data</span><br><span class="line">ln -s /data/mysql-data/ /usr/local/mysql/data</span><br><span class="line">chown -R mysql. /data/mysql-data/</span><br><span class="line">chown -R mysql. /usr/local/mysql/data/</span><br><span class="line">cp support-files/mysql.server /etc/init.d/mysql</span><br><span class="line">rm -rf /etc/my.cnf</span><br><span class="line">yum install -y perl-Module-Install.noarch</span><br><span class="line">perl scripts/mysql_install_db --user=mysql</span><br></pre></td></tr></table></figure>

<p>[root@bogon mysql]# vim /usr/local/mysql/my.cnf</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"># For advice on how to change settings please see</span><br><span class="line"># http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html</span><br><span class="line"></span><br><span class="line">[mysqld]</span><br><span class="line"></span><br><span class="line"># Remove leading # and set to the amount of RAM for the most important data</span><br><span class="line"># cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.</span><br><span class="line">innodb_buffer_pool_size = 128M</span><br><span class="line"></span><br><span class="line"># Remove leading # to turn on a very important data integrity option: logging</span><br><span class="line"># changes to the binary log between backups.</span><br><span class="line">log_bin</span><br><span class="line"></span><br><span class="line"># These are commonly set, remove the # and set as required.</span><br><span class="line">basedir = /usr/local/mysql</span><br><span class="line">datadir = /usr/local/mysql/data</span><br><span class="line"># port = .....</span><br><span class="line"># server_id = .....</span><br><span class="line">socket = /tmp/mysql.sock</span><br><span class="line">bind-address=172.25.196.66</span><br><span class="line"></span><br><span class="line"># Remove leading # to set options mainly useful for reporting servers.</span><br><span class="line"># The server defaults are faster for transactions and fast SELECTs.</span><br><span class="line"># Adjust sizes as needed, experiment to find the optimal values.</span><br><span class="line">join_buffer_size = 128M</span><br><span class="line">sort_buffer_size = 2M</span><br><span class="line">read_rnd_buffer_size = 2M  </span><br><span class="line"></span><br><span class="line">sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES</span><br><span class="line">~</span><br></pre></td></tr></table></figure>

<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">ln -s /usr/local/mysql /usr/local/mysql-5.6.35</span><br><span class="line">service mysql start</span><br><span class="line">netstat -plnt |grep 3306</span><br><span class="line">chkconfig mysql on</span><br><span class="line">mkdir -p /var/lib/mysql/</span><br><span class="line">ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock</span><br></pre></td></tr></table></figure>

<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"># 添加环境变量</span><br><span class="line">echo &quot;PATH=$PATH:/usr/local/mysql/bin&quot; &gt;&gt;/etc/profile</span><br><span class="line">echo &quot;export PATH&quot; &gt;&gt;/etc/profile</span><br><span class="line">source /etc/profile</span><br><span class="line">service mysql restart</span><br><span class="line">./bin/mysqladmin -u root password &apos;root@appinside&apos;</span><br><span class="line">./bin/mysqladmin -u root -h 172.25.196.66 password &apos;root@appinside&apos;</span><br><span class="line">echo &quot;/usr/local/mysql/lib/&quot; &gt;&gt;/etc/ld.so.conf</span><br><span class="line">ldconfig</span><br></pre></td></tr></table></figure>

<p>6，安装resin</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">cd /usr/local/</span><br><span class="line">wget http://www.caucho.com/download/resin-4.0.49.tar.gz</span><br><span class="line">tar xf resin-4.0.49.tar.gz</span><br><span class="line">ln -s resin-4.0.49 resin</span><br></pre></td></tr></table></figure>

<p>7，安装maven</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">cd /mnt</span><br><span class="line">tar fx apache-maven-3.5.4-bin.tar.gz</span><br><span class="line">mv apache-maven-3.5.4 /usr/local/maven</span><br><span class="line">cp /etc/profile /etc/profile.bak</span><br><span class="line">echo &quot;export MVEN_HOME=/usr/local/maven&quot; &gt;&gt;/etc/profile</span><br><span class="line">echo &quot;export PATH=$MVEN_HOME/bin:$PATH&quot; &gt;&gt;/etc/profile</span><br><span class="line">source /etc/profile</span><br><span class="line">mvn -version</span><br></pre></td></tr></table></figure>

<p>8,安装web管理系统开发环境nvm</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash</span><br><span class="line">source ~/.bashrc</span><br><span class="line">nvm install v8.11.3</span><br><span class="line">npm install -g pm2 --registry=https://registry.npm.taobao.org</span><br></pre></td></tr></table></figure>

<p>9,安装bison组件和flex组件</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum -y install bison flex</span><br></pre></td></tr></table></figure>

<p>10,安装Java语言工具包</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">cd /mnt</span><br><span class="line">tar fx thirdparty.tgz</span><br><span class="line">cd  thirdparty/tars-1.5.0/;ls</span><br><span class="line">-----&gt;</span><br><span class="line">build  docs           Install_faq.en.md  Install.md          Introduction.md  LICENSE.TXT  php      README.en.md  tup</span><br><span class="line">cpp    Install.en.md  Install_faq.md     Introduction.en.md  java             nodejs       plugins  README.md     web</span><br><span class="line"></span><br><span class="line">cd java</span><br><span class="line">mvn clean install</span><br><span class="line">mvn clean install -f core/client.pom.xml</span><br><span class="line">mvn clean install -f core/server.pom.xml</span><br></pre></td></tr></table></figure>

<p>12、安装c++环境</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">yum -y install dos2unix flex bison</span><br><span class="line"></span><br><span class="line">cd /mnt/thirdparty/tars-1.5.0/cpp/thirdparty</span><br><span class="line">git clone https://github.com/Tencent/rapidjson.git</span><br><span class="line"></span><br><span class="line">cd /mnt/thirdparty/tars-1.5.0/cpp/build/</span><br><span class="line">./build.sh all</span><br><span class="line">mkdir /usr/local/tars</span><br><span class="line">make install</span><br></pre></td></tr></table></figure>

<p>13、tars数据库环境初始化</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">mysql -uroot -proot@appinside -e &quot;grant all on *.* to &apos;tars&apos;@&apos;%&apos; identified by &apos;tars2015&apos; with grant option;&quot;</span><br><span class="line">mysql -uroot -proot@appinside -e &quot;grant all on *.* to &apos;tars&apos;@&apos;localhost&apos; identified by &apos;tars2015&apos; with grant option;&quot;</span><br><span class="line">mysql -uroot -proot@appinside -e &quot;grant all on *.* to &apos;tars&apos;@&apos;$&#123;MachineName&#125;&apos; identified by &apos;tars2015&apos; with grant option;&quot;</span><br><span class="line">mysql -uroot -proot@appinside -e &quot;flush privileges;&quot;</span><br></pre></td></tr></table></figure>

<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">cd /mnt/thirtparty/tars-1.5.0/cpp/framework/sql</span><br><span class="line">sed -i &quot;s/192.168.2.131/172.25.196.66/g&quot; `grep 192.168.2.131 -rl ./*`</span><br><span class="line">sed -i &quot;s/db.tars.com/172.25.196.66/g&quot; `grep db.tars.com -rl ./*`</span><br><span class="line">chmod u+x exec-sql.sh</span><br><span class="line">./exec-sql.sh</span><br></pre></td></tr></table></figure>

<p>14、打包框架基础服务</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">cd /mnt/thirdparty/tars-1.5.0/cpp/build/</span><br><span class="line">make framework-tar</span><br><span class="line"></span><br><span class="line">make tarsstat-tar</span><br><span class="line">make tarsnotify-tar</span><br><span class="line">make tarsproperty-tar</span><br><span class="line">make tarslog-tar</span><br><span class="line">make tarsquerystat-tar</span><br><span class="line">make tarsqueryproperty-tar</span><br></pre></td></tr></table></figure>

<p>15、安装核心基础服务</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">mkdir -p /usr/local/app/tars/</span><br><span class="line">cd /mnt/thirtyparty/tars-1.5.0/cpp/build</span><br><span class="line"></span><br><span class="line">cp framework.tgz /usr/local/app/tars/</span><br><span class="line">cd /usr/local/app/tars</span><br><span class="line">tar xf framework.tgz</span><br><span class="line"></span><br><span class="line">sed -i &quot;s/192.168.2.131/172.25.196.66/g&quot; `grep 192.168.2.131 -rl ./*`</span><br><span class="line">sed -i &quot;s/db.tars.com/172.25.196.66/g&quot; `grep db.tars.com -rl ./*`</span><br><span class="line">sed -i &quot;s/registry.tars.com/172.25.196.66/g&quot; `grep registry.tars.com -rl ./*`</span><br><span class="line">sed -i &quot;s/web.tars.com/172.25.196.66/g&quot; `grep web.tars.com -rl ./*`</span><br><span class="line"></span><br><span class="line">chmod u+x tars_install.sh</span><br><span class="line">./tars_install.sh</span><br><span class="line">./tarspatch/util/init.sh</span><br></pre></td></tr></table></figure>

<p>16、安装web管理系统</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">cd /mnt/thirtparty/tars-1.5.0/web/</span><br><span class="line">sed -i &quot;s/db.tars.com/172.25.196.66/g&quot; `grep db.tars.com -rl ./src/main/resources/*`</span><br><span class="line">sed -i &quot;s/registry1.tars.com/172.25.196.66/g&quot; `grep registry1.tars.com -rl ./src/main/resources/*`</span><br><span class="line">sed -i &quot;s/registry2.tars.com/172.25.196.66/g&quot; `grep registry2.tars.com -rl ./src/main/resources/*`</span><br><span class="line"></span><br><span class="line">mvn clean package</span><br><span class="line">cp ./target/tars.war /usr/local/resin/webapps/</span><br><span class="line">#./web/target/tars/WEB-INF/classes/log4j.properties  这里可以修改日志目录</span><br><span class="line">mkdir -p /data/log/tars/</span><br><span class="line">mv /usr/local/resin/conf/resin.xml /usr/local/resin/conf/resin.xml.backup</span><br></pre></td></tr></table></figure>

<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br></pre></td><td class="code"><pre><span class="line">cat &gt; /usr/local/resin/conf/resin.xml &lt;&lt; EOF</span><br><span class="line">&lt;!--</span><br><span class="line">   - Resin 4.0 configuration file.</span><br><span class="line">  --&gt;</span><br><span class="line">&lt;resin xmlns=&quot;http://caucho.com/ns/resin&quot;</span><br><span class="line">       xmlns:resin=&quot;urn:java:com.caucho.resin&quot;&gt;</span><br><span class="line"></span><br><span class="line">  &lt;!-- property-based Resin configuration --&gt;</span><br><span class="line">  &lt;resin:properties path=&quot;\$&#123;__DIR__&#125;/resin.properties&quot; optional=&quot;true&quot;/&gt;</span><br><span class="line"></span><br><span class="line">  &lt;resin:if test=&quot;\$&#123;properties_import_url&#125;&quot;&gt;</span><br><span class="line">     &lt;resin:properties path=&quot;\$&#123;properties_import_url&#125;&quot;</span><br><span class="line">                    optional=&quot;true&quot; recover=&quot;true&quot;/&gt;</span><br><span class="line">  &lt;/resin:if&gt;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">  &lt;!-- Logging configuration for the JDK logging API --&gt;</span><br><span class="line">  &lt;log-handler name=&quot;&quot; level=&quot;all&quot; path=&quot;stdout:&quot;</span><br><span class="line">               timestamp=&quot;[%y-%m-%d %H:%M:%S.%s]&quot;</span><br><span class="line">               format=&quot; &#123;\$&#123;thread&#125;&#125; \$&#123;log.message&#125;&quot;/&gt;</span><br><span class="line">               </span><br><span class="line">  &lt;!--</span><br><span class="line">     - Alternative pseudo-TTCC log format</span><br><span class="line">     -</span><br><span class="line">     - &lt;log-handler name=&quot;&quot; level=&quot;all&quot; path=&quot;stdout:&quot;</span><br><span class="line">     -           timestamp=&quot;%y-%m-%d %H:%M:%S.%s&quot;</span><br><span class="line">     -           format=&quot; [\$&#123;thread&#125;] \$&#123;log.level&#125; \$&#123;log.shortName&#125; - \$&#123;log.message&#125;&quot;/&gt;</span><br><span class="line">    --&gt;</span><br><span class="line">   </span><br><span class="line">  &lt;!--</span><br><span class="line">     - level=&apos;info&apos; for production</span><br><span class="line">     - &apos;fine&apos; or &apos;finer&apos; for development and troubleshooting</span><br><span class="line">    --&gt;</span><br><span class="line">  &lt;logger name=&quot;&quot; level=&quot;\$&#123;log_level?:&apos;info&apos;&#125;&quot;/&gt;</span><br><span class="line"></span><br><span class="line">  &lt;logger name=&quot;com.caucho.java&quot; level=&quot;config&quot;/&gt;</span><br><span class="line">  &lt;logger name=&quot;com.caucho.loader&quot; level=&quot;config&quot;/&gt;</span><br><span class="line"></span><br><span class="line">  &lt;!--</span><br><span class="line">     - Default configuration applied to all clusters, including</span><br><span class="line">     - HTTP, HTTPS, and /resin-admin configuration.</span><br><span class="line">    --&gt;</span><br><span class="line">  &lt;resin:import path=&quot;\$&#123;__DIR__&#125;/cluster-default.xml&quot;/&gt;</span><br><span class="line"> </span><br><span class="line">  &lt;!--</span><br><span class="line">     - health configuration</span><br><span class="line">    --&gt;</span><br><span class="line">  &lt;resin:import path=&quot;\$&#123;__DIR__&#125;/health.xml&quot;/&gt;</span><br><span class="line"></span><br><span class="line"> </span><br><span class="line">  &lt;!--</span><br><span class="line">     - Remote management requires at least one enabled admin user.</span><br><span class="line">    --&gt;</span><br><span class="line">  &lt;resin:AdminAuthenticator&gt;</span><br><span class="line">    &lt;user name=&quot;\$&#123;admin_user&#125;&quot; password=&quot;\$&#123;admin_password&#125;&quot;/&gt;</span><br><span class="line">    </span><br><span class="line">    &lt;resin:import path=&quot;\$&#123;__DIR__&#125;/admin-users.xml&quot; optional=&quot;true&quot;/&gt;</span><br><span class="line">  &lt;/resin:AdminAuthenticator&gt;</span><br><span class="line"></span><br><span class="line">  &lt;!--</span><br><span class="line">     - For clustered systems, create a password in as cluster_system_key</span><br><span class="line">    --&gt;</span><br><span class="line">  &lt;cluster-system-key&gt;\$&#123;cluster_system_key&#125;&lt;/cluster-system-key&gt;</span><br><span class="line"></span><br><span class="line">  &lt;!--</span><br><span class="line">     - For production sites, change dependency-check-interval to something</span><br><span class="line">     - like 600s, so it only checks for updates every 10 minutes.</span><br><span class="line">    --&gt;</span><br><span class="line">  &lt;dependency-check-interval&gt;\$&#123;dependency_check_interval?:&apos;2s&apos;&#125;&lt;/dependency-check-interval&gt;</span><br><span class="line"></span><br><span class="line">  &lt;!-- For resin.properties dynamic cluster joining --&gt;</span><br><span class="line">  &lt;home-cluster&gt;\$&#123;home_cluster&#125;&lt;/home-cluster&gt;</span><br><span class="line">  &lt;home-server&gt;\$&#123;home_server&#125;&lt;/home-server&gt;</span><br><span class="line">  &lt;elastic-server&gt;\$&#123;elastic_server&#125;&lt;/elastic-server&gt;</span><br><span class="line">  &lt;elastic-dns&gt;\$&#123;elastic_dns&#125;&lt;/elastic-dns&gt;</span><br><span class="line"></span><br><span class="line">  &lt;!--</span><br><span class="line">     - Configures the main application cluster.  Load-balancing configurations</span><br><span class="line">     - will also have a web cluster.</span><br><span class="line">    --&gt;</span><br><span class="line">  &lt;cluster id=&quot;app&quot;&gt;</span><br><span class="line">    &lt;!-- define the servers in the cluster --&gt;</span><br><span class="line">    &lt;server-multi id-prefix=&quot;app-&quot; address-list=&quot;\$&#123;app_servers&#125;&quot; port=&quot;6800&quot;/&gt;</span><br><span class="line"></span><br><span class="line">    &lt;host-default&gt;</span><br><span class="line">      &lt;!-- creates the webapps directory for .war expansion --&gt;</span><br><span class="line">      &lt;web-app-deploy path=&quot;webapps&quot;</span><br><span class="line">                      expand-preserve-fileset=&quot;WEB-INF/work/**&quot;</span><br><span class="line">                      multiversion-routing=&quot;\$&#123;webapp_multiversion_routing&#125;&quot;</span><br><span class="line">                      path-suffix=&quot;\$&#123;elastic_webapp?resin.id:&apos;&apos;&#125;&quot;/&gt;</span><br><span class="line">    &lt;/host-default&gt;</span><br><span class="line"></span><br><span class="line">    &lt;!-- auto virtual host deployment in hosts/foo.example.com/webapps --&gt;</span><br><span class="line">    &lt;host-deploy path=&quot;hosts&quot;&gt;</span><br><span class="line">      &lt;host-default&gt;</span><br><span class="line">        &lt;resin:import path=&quot;host.xml&quot; optional=&quot;true&quot;/&gt;</span><br><span class="line">      &lt;/host-default&gt;</span><br><span class="line">    &lt;/host-deploy&gt;</span><br><span class="line"></span><br><span class="line">    &lt;!-- the default host, matching any host name --&gt;</span><br><span class="line">    &lt;host id=&quot;&quot; root-directory=&quot;.&quot;&gt;</span><br><span class="line">      &lt;!--</span><br><span class="line">         - webapps can be overridden/extended in the resin.xml</span><br><span class="line">        --&gt;</span><br><span class="line">      &lt;web-app id=&quot;/&quot; document-directory=&quot;webapps/tars&quot;/&gt;</span><br><span class="line"></span><br><span class="line">    &lt;/host&gt;</span><br><span class="line">      </span><br><span class="line">    &lt;resin:if test=&quot;\$&#123;resin_doc&#125;&quot;&gt;</span><br><span class="line">      &lt;host id=&quot;\$&#123;resin_doc_host&#125;&quot; root-directory=&quot;\$&#123;resin_doc_host&#125;&quot;&gt;</span><br><span class="line">        &lt;web-app id=&quot;/resin-doc&quot; root-directory=&quot;\$&#123;resin.root&#125;/doc/resin-doc&quot;/&gt;</span><br><span class="line">      &lt;/host&gt;</span><br><span class="line">    &lt;/resin:if&gt;</span><br><span class="line">  &lt;/cluster&gt;</span><br><span class="line"></span><br><span class="line">  &lt;cluster id=&quot;web&quot;&gt;</span><br><span class="line">    &lt;!-- define the servers in the cluster --&gt;</span><br><span class="line">    &lt;server-multi id-prefix=&quot;web-&quot; address-list=&quot;\$&#123;web_servers&#125;&quot; port=&quot;6810&quot;/&gt;</span><br><span class="line"></span><br><span class="line">    &lt;host id=&quot;&quot; root-directory=&quot;web&quot;&gt;</span><br><span class="line">      &lt;web-app id=&quot;&quot;&gt;</span><br><span class="line">        &lt;resin:LoadBalance regexp=&quot;&quot; cluster=&quot;app&quot;/&gt;</span><br><span class="line">      &lt;/web-app&gt;</span><br><span class="line">    &lt;/host&gt;</span><br><span class="line">  &lt;/cluster&gt;</span><br><span class="line"></span><br><span class="line">  &lt;cluster id=&quot;memcached&quot; xmlns:memcache=&quot;urn:java:com.caucho.memcached&quot;&gt;</span><br><span class="line">    &lt;!-- define the servers in the cluster --&gt;</span><br><span class="line">    &lt;server-multi id-prefix=&quot;memcached-&quot; address-list=&quot;\$&#123;memcached_servers&#125;&quot; port=&quot;6820&quot;&gt;</span><br><span class="line">      &lt;!-- listen for the memcache protocol --&gt;</span><br><span class="line">      &lt;listen port=&quot;\$&#123;memcached_port?:11211&#125;&quot;</span><br><span class="line">              keepalive-timeout=&quot;600s&quot; socket-timeout=&quot;600s&quot;&gt;</span><br><span class="line">        &lt;memcache:MemcachedProtocol/&gt;</span><br><span class="line">      &lt;/listen&gt;</span><br><span class="line">    &lt;/server-multi&gt;</span><br><span class="line">  &lt;/cluster&gt;</span><br><span class="line"> </span><br><span class="line">  &lt;cluster id=&quot;proxycache&quot;&gt;</span><br><span class="line">    &lt;!-- define the servers in the cluster --&gt;</span><br><span class="line">    &lt;server-multi id-prefix=&quot;proxycache-&quot; address-list=&quot;\$&#123;proxycache_servers&#125;&quot; port=&quot;6830&quot;/&gt;</span><br><span class="line"></span><br><span class="line">    &lt;host id=&quot;&quot; root-directory=&quot;proxycache&quot;&gt;</span><br><span class="line">      &lt;web-app id=&quot;&quot;&gt;</span><br><span class="line">        &lt;resin:HttpProxy regexp=&quot;.*&quot;&gt;</span><br><span class="line">          &lt;!-- backend HTTP servers to proxy to --&gt;</span><br><span class="line">          &lt;addresses&gt;\$&#123;backend_servers&#125;&lt;/addresses&gt;</span><br><span class="line">        &lt;/resin:HttpProxy&gt;</span><br><span class="line">      &lt;/web-app&gt;</span><br><span class="line">    &lt;/host&gt;</span><br><span class="line">  &lt;/cluster&gt;</span><br><span class="line"></span><br><span class="line">&lt;/resin&gt;</span><br><span class="line">EOF</span><br></pre></td></tr></table></figure>

<p>17、现在可以访问8080端口的web管理系统了</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">/usr/local/resin/bin/resin.sh start</span><br></pre></td></tr></table></figure>

<p><a href="http://172.25.196.66:8080" target="_blank" rel="noopener">http://172.25.196.66:8080</a></p>
<img src="/blog/2019/10/25/tars框架环境基础搭建/1.png">



<p>OK   这样一个tencent的微服务架构就搭建完成了！  快来试试吧！tars就先到这里，后续会持续更新其他。。。</p>

    </div>

    

    
        <div class="post-tags">
            <i class="fa fa-tags" aria-hidden="true"></i>
            <a href="/blog/tags/tars/">#tars</a> <a href="/blog/tags/腾讯微服务/">#腾讯微服务</a> <a href="/blog/tags/tars环境搭建/">#tars环境搭建</a> <a href="/blog/tags/微服务架构/">#微服务架构</a>
        </div>
    

    <!-- Comments -->
    

</div>
        </section>

    </div>
</div>


</div>

<!-- Footer -->
<div class="push"></div>

<footer class="footer-content">
    <div class="container">
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 footer-about">
                <h2>About</h2>
                <p>
                    This theme was developed by <a href="https://github.com/klugjo">Jonathan Klughertz</a>. The source code is available on Github. Create Websites. Make Magic.
                </p>
            </div>
            
    <div class="col-xs-6 col-sm-6 col-md-3 col-lg-3 recent-posts">
        <h2>Recent Posts</h2>
        <ul>
            
            <li>
                <a class="footer-post" href="/blog/2019/10/25/tars框架环境基础搭建/">tars框架环境基础搭建</a>
            </li>
            
            <li>
                <a class="footer-post" href="/blog/2019/10/20/认识tars框架/">认识tars框架</a>
            </li>
            
            <li>
                <a class="footer-post" href="/blog/2019/10/05/redis数据迁移备份与恢复/">redis数据迁移备份与恢复</a>
            </li>
            
            <li>
                <a class="footer-post" href="/blog/2019/09/21/负载均衡的5种策略/">负载均衡的5种策略</a>
            </li>
            
        </ul>
    </div>



            
        </div>
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                <ul class="list-inline footer-social-icons">
                    
                    <li class="list-inline-item">
                        <a href="https://github.com/klugjo/hexo-theme-alpha-dust">
                            <span class="footer-icon-container">
                                <i class="fa fa-github"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="https://twitter.com/?lang=en">
                            <span class="footer-icon-container">
                                <i class="fa fa-twitter"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="https://www.facebook.com/">
                            <span class="footer-icon-container">
                                <i class="fa fa-facebook"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="https://www.instagram.com/">
                            <span class="footer-icon-container">
                                <i class="fa fa-instagram"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="https://dribbble.com/">
                            <span class="footer-icon-container">
                                <i class="fa fa-dribbble"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="https://plus.google.com/">
                            <span class="footer-icon-container">
                                <i class="fa fa-google-plus"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="https://www.behance.net/">
                            <span class="footer-icon-container">
                                <i class="fa fa-behance"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="https://500px.com/">
                            <span class="footer-icon-container">
                                <i class="fa fa-500px"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="mailto:test@example.com">
                            <span class="footer-icon-container">
                                <i class="fa fa-envelope-o"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="\#">
                            <span class="footer-icon-container">
                                <i class="fa fa-rss"></i>
                            </span>
                        </a>
                    </li>
                    
                </ul>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                <div class="footer-copyright">
                    @Untitled. All right reserved | Design & Hexo <a href="http://www.codeblocq.com/">Jonathan Klughertz</a>
                </div>
            </div>
        </div>
    </div>
</footer>

<!-- After footer scripts -->

<!-- jQuery -->
<script src="//code.jquery.com/jquery-2.1.4.min.js"></script>

<!-- Tween Max -->
<script src="//cdnjs.cloudflare.com/ajax/libs/gsap/1.18.5/TweenMax.min.js"></script>

<!-- Gallery -->
<script src="//cdnjs.cloudflare.com/ajax/libs/featherlight/1.3.5/featherlight.min.js" type="text/javascript" charset="utf-8"></script>

<!-- Custom JavaScript -->
<script src="/blog/js/main.js"></script>

<!-- Disqus Comments -->



</body>

</html>